<%@page import="cn.yi.newsys.pojo.Comment"%>
<%@page import="cn.yi.newsys.service.impl.CommentServiceImpl"%>
<%@page import="cn.yi.newsys.service.CommentService"%>
<%@page import="java.io.File"%>
<%@page import="cn.yi.newsys.service.impl.NewsServiceImpl"%>
<%@page import="cn.yi.newsys.service.NewsService"%>
<%@page import="cn.yi.newsys.pojo.NewsCategory"%>
<%@page import="cn.yi.newsys.service.impl.NewsCategoryServiceImpl"%>
<%@page import="cn.yi.newsys.service.NewsCategoryService"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="cn.yi.newsys.pojo.News"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!--taglib 是标签库   uri用于加载指定库    prefix是前缀，可以自定义，通常用"c"  -->
<!--java.sun.com/jsp/jstl/core  核心标签库  -->
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
	/* NewsService ns = new NewsServiceImpl() ;
	List<News> list = ns.getAllNews() ;
	String obj = request.getParameter("id") ;
	int num = 0 ;
	
	boolean flag = false ;
	for(News news : list){
		if(String.valueOf(news.getNid()).equals(obj)){
			flag = true ;
			break ;
		}
	}
	if(obj == null || !obj.matches("[0-9]+") || !flag){
		out.println("<script>alert('数据传输错误！');location.href='index.jsp';</script>");
	}else{		
		num = Integer.valueOf(obj) ;
		session.setAttribute("newsid", num) ;
		News n = ns.getNewByID(num) ;
		NewsCategoryService ncs = new NewsCategoryServiceImpl() ;
		if(n != null){
			pageContext.setAttribute("news",n) ;
		}
	} */
 %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <!--声明文档兼容模式，表示使用IE浏览器的最新模式-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!--设置视口的宽度(值为设备的理想宽度)，页面初始缩放值<理想宽度/可见宽度>-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>新闻浏览页面</title>

    <!-- Bootstrap的样式文件-->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="shortcut icon" href="images/favicon.ico" mce_href="images/favicon.ico" type="image/x-icon" >
    <style>
        .text-content {
            font-size: 16px;
            line-height: 30px;
        }
        .text-red{
            color: red;
        }
        .bbs  li{padding: 10px 0; border-bottom: 1px #999999 dashed;
            overflow: hidden;}
        .bbs  li div{float: left; width: 60px; margin-right: 10px;}
        .bbs  li div img{ border-radius:50%; width: 60px;}
        .bbs  li h1{float: left; width: 520px; font-size: 16px; line-height: 35px;}
        .bbs  li p{color: #666666; line-height: 25px; font-size: 12px; }
    </style>

	<!--使用 param 对象可以直接用于获取 URL 中的参数数据  -->
	<input type="hidden" value="${param.id }" />
</head>
<!--导航栏-->
<%@ include file="header.jsp" %>
<!--通栏广告-->
<div class="container" style="margin-top: -15px">
    <img src="images/wy.jpg" width="100%">
</div>
<div class="container" style="margin-top: 10px">
    <ul class="breadcrumb">
        <li><a href="#">国内</a></li>
        <li class="active">新闻正文</li>
    </ul>
    <!--输出一个值  -->
    <h1><c:out value="${news.tittle }"/></h1>
    <!--设置一个值  -->
    <c:set var="id" value="${param.id }" />
    <hr>
    <h3>发布时间：${news.dateTime } 新闻来源：${news.author }
        <span class="glyphicon glyphicon-time pull-right">&nbsp;</span>
        <span class="glyphicon glyphicon-fire pull-right">&nbsp;</span>
        <span class="glyphicon glyphicon-eye-open pull-right">&nbsp;</span>
        <span class="glyphicon glyphicon-comment pull-right">&nbsp;</span>
        <span class="glyphicon glyphicon-grain pull-right">&nbsp;</span>
        <span class="glyphicon glyphicon-apple pull-right">&nbsp;</span>
    </h3>
    <hr>
</div>
<!--新闻图片  -->
<c:if test="${!empty news.imgPath }">
	<div><img src="upload/${news.imgPath }" height="400px" width="1000px" /></div>
</c:if>
<div class="container">
    <div class="row">
        <div class="col-md-9">
            <div class="panel panel-default">
                <div class="panel-body text-content">
                    ${news.content }
                </div>
            </div>
            <div class="panel panel-default">
                <h3>&nbsp;&nbsp;<span class="glyphicon glyphicon-th-list">&nbsp;</span>网友评论<small class="pull-right">
                <span class="text-red">101</span>条评论|<span class="text-red">5759</span>人参与网友评论</small></h3>
                <form class="form-horizontal" action="CommentServlet" role="form">
                	<input type="hidden" name="action" value="add" />
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">
                        <c:if test="${!empty sessionScope.User }">
                        	${sessionScope.User.userName }
                        </c:if>
                        <c:if test="${empty sessionScope.User }">
                        	用户名
                        </c:if>
                        </label>
                        <div class="col-sm-10">
                            <textarea id="username" name="comment" class="form-control" rows="5"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="submit" class="btn btn-default">发布</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="panel panel-default">
                <ul class="bbs">            
                 	<!--判断 pageBean 是否为空  -->
                 	<c:if test="${!empty comBean.lisr}">
                 		<c:forEach items="${comBean.lisr }" var="comment">
		                	<li>
		                       <div><img src="images/tou0${random }.jpg"></div>
		                       <h1>${comment.ccontent }</h1>
		                       <p>${comment.cdate }</p>
		                   </li>
                 		</c:forEach>
                 	</c:if>
                 	
                </ul>
            </div>
        </div>
        <div class="col-md-3">
            <div class="panel panel-default" style="margin-left: -15px">
                <h4 style="text-indent: 1em">推荐新闻</h4>
                <ul class="list-unstyled">
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                </ul>
            </div>
            <div class="panel panel-default" style="margin-left: -15px">
                <img src="images/readad.jpg" width="100%"/>
            </div>
            <div class="panel panel-default" style="margin-left: -15px">
                <h4 style="text-indent: 1em">阅读排行</h4>
                <ul class="list-unstyled">
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>
<!--友情链接和版权信息-->
<div class="container" style="margin-top: 10px;">
    <div class="row">
        <div class="" align="center">
            <ul class="list-inline">
                <li><a href="#">关于我们</a></li>
                <li><a href="#">联系我们</a></li>
                <li><a href="#">招贤纳士</a></li>
                <li><a href="#">法律声明</a></li>
                <li><a href="#">友情链接</a></li>
                <li><a href="#">支付方式</a></li>
                <li><a href="#">配送方式</a></li>
                <li><a href="#">服务声明</a></li>
                <li><a href="#">广告声明</a></li>
            </ul>
        </div>
        <%@ include file="footer.jsp" %>
    </div>
</div>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="js/jquery-1.12.4.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>